<?
//Config 0.0.3
class sym_config extends symbiont{
    public function ___main($design){
        global $sql;
        if(!$design) $design='symbionts/config/main';
        $d=new design($design, 'config', false);
        $this->items='';
        $rows=$sql->select_each('config');
        foreach($rows as $val){
            $this->id=$val['id'];
            $this->name=$val['name'];
            $this->value=$val['value']?$val['value']:'(empty)';
            $this->items.=design::run($this->item);
        }
        $d->inc();
    }
    public function ___db_edit(){
        global $sql, $user;
        if($user->access_level<9) return 0;
        if(isset($_POST['id'])&&isset($_POST['name'])&&isset($_POST['value'])){
            $id=data::number($_POST['id']);
            $name=data::word($_POST['name']);
            $value=data::html_view($_POST['value']);
            if($sql->update('config', array('value'=>$value), array('id'=>$id), 1)){
                return 1;
            }
            else{
                return 0;
            }
        }
        return 0;
    }
}
?>